package priv.pront.code.lanqiao.competition.course.date0329;

import java.util.*;

// fixme 二分90重复数据出不来
public class 化装晚会 {

    static int N, S,left, right, target, count = 0,cur;
    static int[] arr;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        S = scanner.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = scanner.nextInt();
        }
        Arrays.sort(arr);
        for (int i = 0; i < N; i++) {
            left = i;
            right = N - 1;
            target = S - arr[i];
            if(arr[N - 1] < target){
                count += N - i - 1;
            }else{
                while (left <= right) {
                    int mid = left + (right - left) / 2;
                    while(mid != N -1 && arr[mid] == arr[mid + 1]){
                        mid = mid + 1;
                    }
                    if (arr[mid] == target || mid != N - 1 && arr[mid] < target && arr[mid + 1] > target) {
                        cur = mid;
                        break;
                    } else if (arr[mid] > target) {
                        right = mid - 1;
                    }  else if (arr[mid] < target) {
                        left = mid + 1;
                    }
                }
                count += Math.max(cur - i, 0);
                cur = 0;
            }
        }
        System.out.println(count);
    }

//    分治 100
    private static void method2(){
        Scanner scanner = new Scanner(System.in);
        List<Integer> a = new ArrayList<>();


        String[] s = scanner.nextLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int l = Integer.parseInt(s[1]);

        for (int i = 0; i < n; i++) {
            a.add(scanner.nextInt());
        }

        Collections.sort(a);

        int count = 0;
        for (int i = 0; i <= n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                if (a.get(i) + a.get(j) <= l) {
                    count++;
                } else {
                    break;
                }
            }
        }
        System.out.println(count);
    }
}
